# -*- coding: utf-8
from django.http import HttpResponse
from django.shortcuts import render
from django.views.decorators import csrf

# 表单
def search_form(request):
    return render(request, 'search_form.html')


# 接收请求数据
def search(request):
    request.encoding = 'utf-8'
    if 'keyword' in request.GET and request.GET['keyword']:
        message = '你搜索的内容为: ' + request.GET['keyword']
    else:
        message = '你提交了空表单'
    return HttpResponse(message)



# 接收POST请求数据
def search_post(request):
    ctx = {}
    if request.POST:
        ctx['rlt'] = request.POST['keyword']
    return render(request, "search_post.html", ctx)